#ifndef CLIENT_H
#define CLIENT_H

#include "NetworkDefinitions.h"
#include "NetworkMessage.h"
#include "NetworkBase.h"
#include "../EventSystem/Event.h"
#include "../Utility/Misc/Timer.h"
#include <vector>
using std::vector;

class Client
{
private:
	typedef void (*MessageParserFunc)(NetworkMessage& _netMsg, Address& _incomingAddress);

	static Socket clientSocket;
	static Address serverAddress;
	static NetworkMessage clientMessage;
	static NetworkHeader clientHeader;
	static unsigned char sequenceNumber;
	static vector<MessageParserFunc> msgParser;
	static Timer timer;
	static unsigned int sequence;
	static float broadcastWait;
	static float msgRate;
	static float msgTimer;
	static bool isRunning;

	//////////////////////////////////////////////////
	// This will be removed for broadcast/master server
	static void GetIPAddress(const char* filename);
	//////////////////////////////////////////////////

	static bool SendBroadcastRequest();
	static bool ServerBroadcastResponse(float _maxWaitTime);
	static void ParseConnectMessage(NetworkMessage& _netMsg, Address& _incomingAddress);
	static void ParseFullMessage(NetworkMessage& _netMsg, Address& _incomingAddress);
	static void ParseShutdownMessage(NetworkMessage& _netMsg, Address& _incomingAddress);
	static void ParsePlayerMoveMessage(NetworkMessage& _netMsg, Address& _incomingAddress);

	static void HandleEvent(Event* _event);

	static void SendMessages();
	static void LoadClientSettings(const char* const _filePath);

public:

	static void Init();
	static void Update();
	static void Shutdown();

	static bool IsRunning() {return isRunning;}
};

#endif